<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>认证中心</title>
</head>
<div style="text-align: center;">这里是认证中心主页</div>
<script src="jquery-1.8.0.min.js"></script>
<script src="loadwith.js"></script>
<script src="main.js"></script>
<script src="https://cdn.bootcss.com/Base64/1.0.2/base64.js"></script>
<script>
    var order = getUrlParam("order");
    switch (order) {
        case "checkLogin":
            checkLogin();
            break;
        default:
            console.log("不支持的order:" + order);
    }
    function checkLogin() {
        var token = localStorage.getItem("token");
        if (token == null || token.length == 0) {
            goLogin();
        } else {
            //有token，检查token是否还有效
        /*    $.ajax({
                type: "get",
                url: "/sso/checkJwt",
                success: function (data) {
                    if(data.code==200){
                        window.localStorage.token=data.token;
                        alert('已登录，跳转到回调页面');
                        window.location.href = getUrlParam("redirect") + "?token=" + localStorage.getItem("token");
                    }else{
                        goLogin();
                    }
                },
                'beforeSend':setHeader
            });*/
            load('get',"/sso/checkJwt",null,calls);
        }
    }
    function calls(data) {
        if(data.code==200){
            window.localStorage.token=data.token;
            alert('已登录，跳转到回调页面');
            window.location.href = getUrlParam("redirect") + "?token=" + localStorage.getItem("token");
        }else{
            goLogin();
        }
    }
    function goLogin() {
        alert("无认证信息，即将跳转到登录页面");
        window.location.href = encodeURI("./login.html?redirect=" + getUrlParam("redirect"));
    }

</script>
</body>
</html>